/*
 * @Author: qin
 * @Date:   2019-04-28
 * +----------------------------------------------------------------------
 * | admin [ 后台管理系统公共配置信息 ]
 * +----------------------------------------------------------------------
 */
layui.define(['jquery', 'configureCom', 'configure'], function (exports) {
    var $ = layui.jquery;
    var configureCom = layui.configureCom;
    var configure = layui.configure;
    var indexEchartFun = {
        // 各市强条统计
        cityQtInit: function () {
            var cityQt = echarts.init(document.getElementById('cityQt'));
            var listAll = [];
            configureCom.getAjax(configure.REPORT_CHECK_REVIEW_STATUS_HTTP).then(function (res) {
                $(res.list).each(function (index, data) {
                    var list = {
                        value: data.qtCount,
                        name: data.name
                    };
                    listAll.push(list);
                });
                var listAlls = listAll.splice(1);//删除数组第一个索引值并返回一个新数组
                var cityQtOption = {
                    tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    calculable: false,
                    series: [
                        {
                            name: '强条数',
                            type: 'pie',
                            selectedMode: 'single',
                            radius: [0, 40],

                            x: '20%',
                            width: '40%',
                            funnelAlign: 'right',
                            max: 1548,

                            itemStyle: {
                                normal: {
                                    label: {
                                        position: 'inner'
                                    },
                                    labelLine: {
                                        show: false
                                    }
                                }
                            },
                            data: [
                                {value: res.list[0].qtCount, name: res.list[0].name}
                            ]
                        },
                        {
                            name: '强条数',
                            type: 'pie',
                            radius: [50, 70],

                            x: '60%',
                            width: '35%',
                            funnelAlign: 'left',
                            max: 1048,

                            data: listAlls
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                cityQt.setOption(cityQtOption);
            });
        },
        //各市建筑业投资份额统计
        cityTzCountInit: function () {
            var cityTzCount = echarts.init(document.getElementById('cityTzCount'));
            var listAll = [];
            configureCom.getAjax(configure.REPORT_CHECK_REVIEW_STATUS_HTTP).then(function (res) {
                $(res.list).each(function (index, data) {
                    var list = {
                        value: data.allInvest,
                        name: data.name
                    };
                    listAll.push(list);
                });
                var listAlls = listAll.splice(1);//删除数组第一个索引值并返回一个新数组
                var cityTzCountOption = {
                    /*tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    series: [
                        {
                            type: 'pie',
                            radius: [20, 40],
                            center: ['50%', '50%'],
                            roseType: 'area',
                            x: '50%',               // for funnel
                            max: 40,                // for funnel
                            sort: 'ascending',     // for funnel
                            data:listAlls
                        }
                    ]*/
                    tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    series: [
                        {
                            name: '访问来源',
                            type: 'pie',
                            radius: '55%',
                            center: ['50%', '60%'],
                            data: listAlls
                            ,
                            itemStyle: {
                                emphasis: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                cityTzCount.setOption(cityTzCountOption);
            });
        },
        //全省各市项目审查业绩统计图
        cityYjInit: function () {
            var listSum = [];
            var listText = [];
            configureCom.getAjax(configure.REPORT_CHECK_REVIEW_STATUS_HTTP).then(function (res) {
                $(res.list).each(function (index, data) {
                    var list1 = {
                        value: data.recordCount
                    };
                    var list2 = '';
                    list2 = data.name;
                    listSum.push(list1);
                    listText.push(list2);
                });
                var listTexts = listText.splice(1);
                var cityYj;
                $('.cityYj').each(function (index, item) {
                    cityYj = echarts.init(item);
                    var cityYjOption = {
                        tooltip: {
                            trigger: 'axis'
                        },
                        grid: {
                            borderWidth: 0
                        },
                        xAxis: [
                            {
                                splitLine: {show: false},
                                splitArea: {show: false},//保留网格区域
                                type: 'category',
                                axisLabel: {
                                    textStyle: {
                                        color: "#fff"
                                    }
                                },
                                data: listTexts
                            }
                        ],
                        color: ['#00c6ff'],
                        yAxis: [
                            {
                                min: 0,
                                splitNumber: 5,
                                position: 'left',
                                max: 2500,
                                axisLabel: {
                                    show: true,
                                    interval: 'auto',    // {number}
                                    margin: 18,
                                    formatter: '{value}',    // Template formatter!
                                    textStyle: {
                                        color: '#fff',
                                        fontFamily: 'verdana',
                                        fontSize: 10,
                                        fontStyle: 'normal',
                                        fontWeight: 'bold'
                                    }
                                },
                                splitLine: {
                                    show: true,
                                    lineStyle: {
                                        color: ['#064866'],
                                        width: 1,
                                        type: 'solid'
                                    }
                                },
                                splitArea: {show: false},//保留网格区域
                                type: 'value'
                            }
                        ],
                        series: [
                            {
                                name: '',
                                type: 'bar',
                                barWidth: 15,//柱图宽度
                                itemStyle: {        //上方显示数值
                                    normal: {
                                        label: {
                                            show: true, //开启显示
                                            position: 'top', //在上方显示
                                            textStyle: { //数值样式
                                                backgroundColor: '#A89463',
                                                borderRadius: [5, 5, 5, 5],
                                                color: 'white',
                                                fontSize: 16
                                            }
                                        }
                                    }
                                },
                                data: listSum
                                //data: [1000, 2000, 1800, 1500, 2100, 1652, 1000, 2000, 1800, 1500, 2100, 1652, 1800, 1500]
                            }
                        ]
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    cityYj.setOption(cityYjOption);
                });
            });
        },
        //各专业强条统计
        specQtInit: function () {
            var specQt = echarts.init(document.getElementById('specQt'));
            var listAll = [];
            configureCom.getAjax(configure.REPORT_CHECK_CHECK_AREA_BY_SPEC_HTTP).then(function (res) {
                $(res.list).each(function (index, data) {
                    var list1 = {
                        name: '总专业',
                        value: data.allQtCount,
                        itemStyle: labelBottom
                    };
                    var list2 = {
                        name: data.name,
                        value: data.qtCount,
                        itemStyle: labelTop
                    };
                    listAll.push(list1 + list2);
                });
                var labelTop = {
                    normal: {
                        label: {
                            show: false,
                            formatter: '{b}',
                            textStyle: {
                                baseline: 'middle'
                            },
                            position: ['10%', '30%']
                        },
                        labelLine: {
                            show: false
                        }
                    }
                };
                var labelFromatter = {
                    normal: {
                        label: {
                            formatter: function (params) {
                                return 100 - params.value + '%'
                            },
                            textStyle: {
                                baseline: 'middle',
                                fontSize: 10,
                                color: '#fdd100'
                            }
                        }
                    }
                };
                var labelBottom = {
                    normal: {
                        color: '#0f3c5c',
                        label: {
                            show: true,
                            position: 'center'
                        },
                        labelLine: {
                            show: false
                        }
                    },
                    emphasis: {
                        color: 'rgba(0,0,0,0)'
                    }
                };
                var radius = [16, 20];
                var specQtOption = {
                    tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    color: ['#3fecff'],
                    calculable: false,
                    series: [
                        {
                            type: 'pie',
                            center: ['10%', '15%'],
                            radius: radius,
                            x: '0%', // for funnel
                            itemStyle: labelFromatter,
                            data: [
                                {name: '总专业', value: res.list[0].allQtCount, itemStyle: labelBottom},
                                {name: res.list[0].specName, value: res.list[0].qtCount, itemStyle: labelTop}
                            ]
                        }, {
                            type: 'pie',
                            center: ['60%', '15%'],
                            radius: radius,
                            x: '20%', // for funnel
                            itemStyle: labelFromatter,
                            data: [
                                {name: 'other', value: 50, itemStyle: labelBottom},
                                {name: '勘察专业', value: 50, itemStyle: labelTop}
                            ]
                        }, {
                            type: 'pie',
                            center: ['10%', '50%'],
                            radius: radius,
                            x: '40%', // for funnel
                            itemStyle: labelFromatter,
                            data: [
                                {name: 'other', value: 70, itemStyle: labelBottom},
                                {name: '暖通专业', value: 30, itemStyle: labelTop}
                            ]
                        },
                        {
                            type: 'pie',
                            center: ['60%', '50%'],
                            radius: radius,
                            x: '60%', // for funnel
                            itemStyle: labelFromatter,
                            data: [
                                {name: 'other', value: 70, itemStyle: labelBottom},
                                {name: '给排水专业', value: 30, itemStyle: labelTop}
                            ]
                        }, {
                            type: 'pie',
                            center: ['10%', '85%'],
                            radius: radius,
                            x: '80%', // for funnel
                            itemStyle: labelFromatter,
                            data: [
                                {name: 'other', value: 80, itemStyle: labelBottom},
                                {name: '结构专业', value: 20, itemStyle: labelTop}
                            ]
                        },
                        {
                            type: 'pie',
                            center: ['60%', '85%'],
                            radius: radius,
                            y: '55%',   // for funnel
                            x: '0%',    // for funnel
                            itemStyle: labelFromatter,
                            data: [
                                {name: 'other', value: 80, itemStyle: labelBottom},
                                {name: '建筑专业', value: 20, itemStyle: labelTop}
                            ]
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                specQt.setOption(specQtOption);
            });
        },
        //全省建筑面积历年趋势图
        areaCountInit: function () {
            var areaCount = echarts.init(document.getElementById('areaCount'));
            var listText = [];
            var listYear = [];
            configureCom.getAjax(configure.REPORT_CHECK_CHECK_AREA_BY_YEAR_HTTP).then(function (res) {

                $(res.list).each(function (index, data) {
                    var Text = '';
                    Text = data.allArea;
                    var Year = '';
                    Year = data.year;

                    listText.push(Text);
                    listYear.push(Year);
                });
                var areaCountOption = {
                    tooltip: {
                        trigger: 'axis'
                    },
                    grid: {
                        x: 55,
                        x2: 100,
                        borderWidth: 0
                    },
                    xAxis: [
                        {
                            splitLine: {show: false},
                            splitArea: {show: false},//保留网格区域
                            type: 'category',
                            axisLabel: {
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            data: listYear
                        }
                    ],
                    color: ['#3fecff'],
                    yAxis: [
                        {
                            min: 0,
                            splitNumber: 5,
                            position: 'left',
                            max: 2500,
                            axisLabel: {
                                show: true,
                                interval: 'auto',    // {number}
                                margin: 5,
                                formatter: '{value}',    // Template formatter!
                                textStyle: {
                                    color: '#fff',
                                    fontSize: 10,
                                    fontStyle: 'normal'
                                }
                            },
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: ['#064866'],
                                    width: 1,
                                    type: 'solid'
                                }
                            },
                            splitArea: {show: false},//保留网格区域
                            type: 'value'
                        }, {
                            type: 'value',
                            name: '',
                            min: 0,
                            max: 100,
                            position: 'left',
                            interval: 10,
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: ['#064866'],
                                    width: 1,
                                    type: 'solid'
                                }
                            },
                            splitArea: {show: false},//保留网格区域
                            axisLabel: {
                                show: true,
                                interval: 'auto',    // {number}
                                margin: 10,
                                formatter: '{value} %',    // Template formatter!
                                textStyle: {
                                    color: '#fff',
                                    fontSize: 10,
                                    fontStyle: 'normal'
                                }
                            }
                        }
                    ],
                    series: [
                        {
                            name: '',
                            type: 'bar',
                            barWidth: 15,//柱图宽度
                            data: listText
                        },
                        {
                            name: '',
                            type: 'line',
                            yAxisIndex: 1,    //这里要设置哪个y轴，默认是最左边的是0，然后1，2顺序来。
                            data: listText,
                            symbolSize: 3,
                            itemStyle: {
                                normal: {
                                    color: "#fdd100"
                                }
                            }
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                areaCount.setOption(areaCountOption);
            });
        }
    };
    exports('indexEchartFun', indexEchartFun);
});
